home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
dtk_demo.zip
/
SAVEVALS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-12
|
2KB
|
74 lines
/* SAVEVALS.C
* last mod.: 12-SEP-91
*/
#include <STDIO.H>
#include <STDLIB.H>
#include <STRING.H>
#include <L_FILE.H>
#include <L_STR.H>
/* structure for saving values in */
struct save_t
{
Uchar id_string[13]; /* 12 id bytes */
Uchar x[21];
int y;
/* substitute variables as required */
} ;
struct save_t save =
{
"oneflewovert", "ABC", 123 /* , ... */
};
/* initial values for save variables */
Uchar buffer[4000];
void main(int argc, char *argv[])
{
printf("The current values are: %s, %d\n",save.x,save.y);
printf("Enter new string value for x: ");
gets_n(save.x,20);
if ( !*trim(save.x) )
exit(0);
printf("\nEnter new integer value for y: ");
gets_n(buffer,5);
if ( !*trim(buffer) )
exit(0);
save.y = atoi(buffer);
switch ( save_values_in_exe(argv[0],&save,sizeof(save),
save.id_string,buffer,sizeof(buffer)) )
{
case 0:
printf("\nValues saved for next run.\n");
break;
case -1:
printf("save_size <= len_id_string.\n");
break;
case -2:
printf("buff_size < 8*save_size.\n");
break;
case -3:
printf("Cannot find .EXE file.\n");
break;
case -4:
printf("Error when reading .EXE file.\n");
break;
case -5:
printf("Cannot locate save structure in .EXE file.\n");
break;
case -6:
printf("File is not an .EXE file.\n");
break;
case -7:
printf("Cannot write save structure to .EXE file.\n");
break;
default:
printf("Unknown error.\n");
}
}